{% extends "base.html" %}

{% block content %}
<script language="javascript" src="/static/js/jquery-1.2.1.pack.js" type="text/javascript"></script>
<script type="text/javascript" src="/static/js/jquery-calendar-pack.js" ></script>
<style type="text/css">@import url(/static/css/jquery-calendar.css);</style>
<script language="javascript" type="text/javascript">
$(document).ready(
	function()
	{
    	popUpCal.regional['zh-cn'] = {dateFormat: 'DMY/'};
		popUpCal.setDefaults(popUpCal.regional['zh-cn']);
	    $('#next_follow_date').calendar({autoPopUp: 'focus',yearRange: '-1:+1'});
	}
);
 </script>
<script language=javascript>

function verify(form){
  if(form.name.value==""){
	alert("Enter the name please!");
	form.name.focus();		
       return false;
	}
  if(form.tel_h.value !=""||form.tel_o.value !=""||form.tel_m.value !=""){

	}
	else{
		alert("Enter tel please");
       return false;
	  }
	 if(form.email.value==0){
	alert("Enter email please");
	form.email.focus();		
       return false;
	}
// if(form.address.value==""){
//	alert("Enter Address please");
//	form.address.focus();		
//       return false;
//	}

return true;
 }

</script>


<table width="600" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" width="430">


<form name='form1' id='form1' action="/saveuser/" method='post' onsubmit='return verify(this);'>
<table width='430' class='grid' cellspacing='1' align='center'><tr><td colspan='2' class='title'>{% ifequal act 'edit' %} Edit {%endifequal%}{{ members.name }}'s infomation</td></tr>
<tr valign='middle' align='left'></tr>

<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Name:</td>
<td class='even'>{% ifequal act 'edit' %}<input type="text" name="name" value="{{ members.name }}" />{%else%}{{ members.name }}{%endifequal%}</td></tr>
{% ifequal act 'show' %}<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Sales</td>
<td class='even'>{{ members.salesperson.name }}</td></tr>{%endifequal%}
<tr valign='middle' align='left'><td class='odd' width='25%'>Job Title:</td>
<td class='even'>{% ifequal act 'edit' %}<input type="text" name="job_title" value="{{ members.job_title }}" />{%else%}{{ members.job_title }}{%endifequal%}</td></tr>

<tr valign='middle' align='left'><td class='odd' width='25%'>Company:</td>
<td class='even'>{% ifequal act 'edit' %}<input type="text" name="company" value="{{ members.company }}" />{%else%}{{ members.company }}{%endifequal%}</td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Tel:</td>
<td class='even'>{% ifequal act 'edit' %}<input type="text" name="tel_h" value="{{ members.tel_h }}" size="10" />{%else%}{{ members.tel_h }}{%endifequal%}(H){% ifequal act 'edit' %}<input type="text" name="tel_o" value="{{ members.tel_o }}" size="10" />{%else%}{{ members.tel_o }}{%endifequal%}(O){% ifequal act 'edit' %}<input type="text" name="tel_m" value="{{ members.tel_m }}" size="13" />{%else%}{{ members.tel_m }}{%endifequal%}(M)</td></tr>

<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>E-mail</td>
<td class='even'>{% ifequal act 'edit' %}<input type="text" name="email" value="{{ members.email }}" />{%else%}{{ members.email }}{%endifequal%}</td></tr>

 <tr valign='middle' align='left'><td class='odd' width='25%'>Received email?</td>
<td class='even'><input name="received_emaill" type="checkbox" value="1" {% if members.received_emaill %}checked{% endif %} />yes</td></tr>
 <tr valign='middle' align='left'><td class='odd' width='25%'>Received hardcopy?</td>
<td class='even'><input name="received_hardcopy" type="checkbox" value="1" {%if members.received_hardcopy%}checked{% endif %} />yes</td></tr>
 <tr valign='middle' align='left'><td class='odd' width='25%'>Consultation with the program consultant</td>
<td class='even'><input name="attendsess" type="checkbox" value="true" {%ifequal members.attendsess 'Y' %}checked{% endifequal %} />yes</td></tr>
<!--
 <tr valign='middle' align='left'><td class='odd' width='25%'><font color='red'>(M&T)</font>Send me more info about:</td>
<td class='even'><input name="mba" type="checkbox" value="1" {%ifequal members.mba 1 %}checked{% endifequal %} />mba&nbsp;<input name="mpa" type="checkbox" value="1" {%ifequal members.mpa 1 %}checked{% endifequal %} />mpa&nbsp;<input name="dba" type="checkbox" value="1" {%ifequal members.dba 1 %}checked{% endifequal %} />dba&nbsp;</td></tr>
-->
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Address</td>
<td class='even'>{% ifequal act 'edit' %}<textarea name="address" cols="40" rows="3">{{ members.address }}</textarea>{%else%}{{ members.address }}{%endifequal%}</td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color='red'>(M&T)</font>Message</td>
<td class='even'>{% ifequal act 'edit' %}<textarea name="message" cols="40" rows="5">{{ members.message }}</textarea>{%else%}{{ members.message }}{%endifequal%}</td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'>Education</td>
<td class='even'>{% ifequal act 'edit' %}<select name="education">
<option value="">Choose Education plz</option>
<option value="1" {% ifequal members.education "1" %}selected{% endifequal %}> Secondary School</option>
<option value="2" {% ifequal members.education "2" %}selected{% endifequal %}>Diploma</option>
<option value="3" {% ifequal members.education "3" %}selected{% endifequal %}>Bachelor's Degree</option>
<option value="4" {% ifequal members.education "4" %}selected{% endifequal %}>Master's Degree</option>
<option value="5" {% ifequal members.education "5" %}selected{% endifequal %}>Ph.D.</option>
</select>{%else%}{{ members.get_education_display }}{%endifequal%}
</td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'>Work Experience</td>
<td class='even'>{% ifequal act 'edit' %}<input type="text" name="work_experience" value="{{ members.work_experience }}" />{%else%}{{ members.work_experience }}{%endifequal%} &nbsp;year(s)</td></tr>

<tr valign='middle' align='left'><td class='odd' width='25%'>Agent</td>
<td class='even'>{% ifequal act 'edit' %}<select name="agent_id">
 <option value="1">Choose Agent plz</option>
  {% for agent in agent %}
   <option value="{{agent.id}}" {% ifequal agent.id members.agent.id %}selected{%endifequal%}>{{agent.name}}</option>
  {% endfor %}
  </select>{%else%}{{ members.agent.name }}{%endifequal%}
</td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'>Further interest</td>
<td class='even'>{% ifequal act 'edit' %}<select name="furtherinterest_id">
 <option value="0">Choose plz</option>
  {% for fi in fi %}
   <option value="{{fi.id}}" {% ifequal fi.id members.furtherinterest.id %}selected{%endifequal%}>{{fi.name}}</option>
  {% endfor %}
  </select>{%else%}{{ members.furtherinterest.name }}{%endifequal%}
</td></tr>

<tr valign='middle' align='left'><td class='odd' width='25%'>Programs</td>
<td class='even'>{% ifequal act 'edit' %}<select name="projects_id">
 <option value="0">Choose plz</option>
  {% for pj in pj %}
   <option value="{{pj.id}}" {% ifequal pj.id members.projects.id %}selected{%endifequal%}>{{pj.name}}</option>
  {% endfor %}
  </select>{%else%}{{ members.projects.name }}{%endifequal%}
</td></tr>

{% ifequal level 'administrators' %}
<tr valign='middle' align='left'><td class='odd' width='25%'>sales</td>
<td class='even'>{% ifequal act 'edit' %}<select name="salesperson_id">
 <option value="0">Choose plz</option>
  {% for sales in sales %}
   <option value="{{sales.id}}" {% ifequal sales.id members.salesperson.id %}selected{%endifequal%}>{{sales.name}}</option>
  {% endfor %}
  </select>{%else%}{{ members.sales.name }}{%endifequal%}
</td></tr>
<!-- user group -->
<tr valign='middle' align='left'><td class='odd' width='25%'>sales Group</td>
<td class='even'>{% ifequal act 'edit' %}<select name="group">
 <option value="0">Choose group</option>
  {% for salesgroup in salesgroup %}
   <option value="{{salesgroup.id}}" {% ifequal salesgroup.id members.men_area %}selected{%endifequal%}>{{salesgroup.name}}</option>
  {% endfor %}
  </select>{%else%}{{ members.sales.name }}{%endifequal%}
</td></tr>
{%endifequal%}

<!--
{% ifequal act 'edit' %}

<tr valign='middle' align='left'><td class='odd' width='25%'></td>
<input type="hidden" name="id" value="{{members.id}}" />
<td class='even'>&nbsp;<input type='submit' class='button' name='submit'  id='submit' value=' Submit '  />&nbsp;&nbsp;<input type='button' class='button' name='back'  id='reset' value=' Back ' onclick="javascrip:history.back(1)" /></form></td></tr>
{%else%}
<tr valign='middle' align='left'><td class='odd' width='25%'></td>
<td class='even'>&nbsp;<input type='button' class='button' name='back'  id='reset' value=' Back ' onclick="javascrip:history.back(1)" /></form></td></tr>

{%endifequal%}
-->
</table>


</td>

<td align="left" valign="top" width="170">
<!-- begin right -->
<table  class='grid' cellspacing='1' align='left'>
<tr><td colspan='3' class='title'>&nbsp;</td></tr>

<tr valign='middle' align='left' ><td class='odd' width='25%'>Interest Level</td>
<td class='even' colspan='2'>{% ifequal act 'edit' %}<select name="interlevel">
<option value="0">Not contacted yet</option>
<option value="1" {% ifequal members.interlevel '1' %}selected{% endifequal %}> HI</option>
<option value="2" {% ifequal members.interlevel '2' %}selected{% endifequal %}>SI</option>
<option value="5" {% ifequal members.interlevel '5' %}selected{% endifequal %}>LI</option>
<option value="3" {% ifequal members.interlevel "3" %}selected{% endifequal %}>NI</option>
<option value="4" {% ifequal members.interlevel "4" %}selected{% endifequal %}>NT</option>
</select>{%else%}{{ members.get_interlevel_display }}{%endifequal%}
</td></tr>
<tr><td colspan='3' class='title'>Follow-up</td></tr>
<tr><td colspan='3'><hr></td></tr>
{% for f_object in f_object %}
<tr><td  class='even' >
{{ f_object.get_status_display }}<br />({{f_object.timeline|date:"y-m-d " }} )
<!-- {% ifequal f_object.status "1" %}Can't reach{% endifequal %}
   {% ifequal f_object.status "2" %}App sch'd{% endifequal %}
   {% ifequal f_object.status "3" %} Under cons{% endifequal %}
   {% ifequal f_object.status "4" %}Call later{% endifequal %}
   {% ifequal f_object.status "5" %}Conflict{% endifequal %}
   {% ifequal f_object.status "6" %}No call{% endifequal %}
   {% ifequal f_object.status "7" %}Enrolled{% endifequal %} --></td>
<td class='odd' width="130">{{f_object.remarks}}</td>
<td class='odd' width='8'><a href="/edit_f/{{ f_object.id}}"><img src="/static/images/icon_edit.gif"border="0" alt="edit" title='edit'></a>&nbsp;&nbsp;<a href="/del_f/{{ f_object.id}}" onclick="return confirm('Are you sure to delete it?');"><img src="/static/images/icon_drop.gif" border="0" alt="delete" title='delete'></a></td></tr>
{% endfor %}
<!--同一客户报了其它project的follow-up -->
{% for t_obj in other_fl_list %}
	<tr><td colspan='3' bgcolor="#ffffff" style="color:blue;"><b>PROGRAM:{{t_obj.project.name}} Follow Up--Sales:{{t_obj.sales.name}}</b></td></tr>
	{% for ff_obj in t_obj.flist %}
	<tr><td  class='even' >
	{{ ff_obj..get_status_display }}<br />({{ff_obj.timeline|date:"y-m-d " }} )
	<!-- {% ifequal f_object.status "1" %}Can't reach{% endifequal %}
	   {% ifequal f_object.status "2" %}App sch'd{% endifequal %}
	   {% ifequal f_object.status "3" %} Under cons{% endifequal %}
	   {% ifequal f_object.status "4" %}Call later{% endifequal %}
	   {% ifequal f_object.status "5" %}Conflict{% endifequal %}
	   {% ifequal f_object.status "6" %}No call{% endifequal %}
	   {% ifequal f_object.status "7" %}Enrolled{% endifequal %} --></td>
	<td class='odd' width="130">{{ff_obj.remarks}}</td>
	<td class='odd' width='8'><a href="/edit_f/{{ ff_obj.id}}"><img src="/static/images/icon_edit.gif"border="0" alt="edit" title='edit'></a>&nbsp;&nbsp;<a href="/del_f/{{ ff_obj.id}}" onclick="return confirm('Are you sure to delete it?');"><img src="/static/images/icon_drop.gif" border="0" alt="delete" title='delete'></a></td></tr>
	{%endfor%}
{% endfor %}
<!--END 同一客户报了其它project的follow-up -->
{% ifequal act 'edit' %}
<tr><td colspan='3' class='title'>Add follow-up</td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'>status:</td>
<td class='even' colspan='2'><select name="status">
<option value="">Choose status plz</option>
<option value="1" > Can't reach</option>
<option value="2" > App sch'd</option>
<option value="3" > Under cons</option>
<option value="4" > Call later</option>
<option value="5" > Conflict</option>
<option value="6" > No call</option>
<option value="7" > Enrolled</option>
<option value="8" > Repeat</option>
<option value="9" > Application</option>
<option value="10" > Dead</option>
</select>
</td></tr>
<tr><td colspan='3' class='even'>
<textarea name="remarks" cols="40" rows="5"></textarea><br />Remark
</td></tr>
<tr><td colspan='3' class='title'>Next Follow</td></tr>
<tr valign='middle' align='left'><td class='odd' width='35%'>Next Follow Date:</td>
<td class='even' colspan='2'>
<input type="text" name="next_follow_date" id="next_follow_date" value="{{next_follow_date_obj.follow_date|date:'d/m/Y'}}" readonly size="12">
</td></tr>
<tr><td colspan='3' class='even'>
<textarea name="next_follow_remark" id="next_follow_remark" cols="40" rows="3">{{next_follow_date_obj.remark}}</textarea><br />Next Follow Remark
</td></tr>
{%endifequal%}
<tr><td colspan='3' class='title'>Sales Record</td></tr>
{% for sr in sr_list %}
<tr><td colspan='3' class='even'>
<font color='blue'>{{sr.starttime}}</font> to <font color='blue'>{%if sr.endtime%}{{sr.endtime}}{%else%}{{today}}{%endif%}</font> &nbsp;sales: <font color='blue'>{{sr.salesperson.name}}</font>
</td></tr>
{% endfor %}
<tr><td colspan='3'><hr></td></tr>
<tr><td colspan='3' class='title'>Other Programs</td></tr>
{% for op in otherproject_list %}
<tr><td colspan='3' class='even'>
{{op.projects.name}}
</td></tr>
{% endfor %}

</table>
<!-- end right -->
<td>
</tr>
<!-- bottom submit button -->
<tr><td colspan='3' class='title'>
{% ifequal act 'edit' %}
<input type="hidden" name="id" value="{{members.id}}" />
<input type="hidden" name="back_url" value="{{back_url}}" />
&nbsp;<input type='submit' class='button' name='submit'  id='submit' value=' Submit '  />&nbsp;&nbsp;<input type='button' class='button' name='back'  id='reset' value=' Back ' onclick="javascrip:history.back(1)" /></form>
{%else%}
&nbsp;<input type='button' class='button' name='back'  id='reset' value=' Back ' onclick="javascrip:history.back(1)" /></form>
{%endifequal%}
</td></tr>
</table>
{% endblock %}
